package com.archie.xunji.guangchang;

import android.content.Intent;
import android.os.Parcelable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import com.archie.xunji.R;
import com.archie.xunji.guangchang.entity.GuangchangData;
import com.lidroid.xutils.BitmapUtils;
import com.meg7.widget.CircleImageView;

public class GuangchangListActivity extends ActionBarActivity implements View.OnClickListener {

    private ImageButton list_square_back;

    private ImageView square_detail_headurl;
    private CircleImageView square_detail_userimg;
    private BitmapUtils bitmapUtils;

    private TextView square_detail_username;
    private TextView square_detail_playcount;
    private TextView square_detail_description;
    private TextView square_detail_createtime;
    private TextView square_detail_location;
    private TextView square_detail_labels;

    private GuangchangData squareEntity;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guangchang_list);
        Intent intent = getIntent();
        Parcelable parcelableExtra = intent.getParcelableExtra("squareEntity");
        squareEntity = (GuangchangData) parcelableExtra;
        bitmapUtils = new BitmapUtils(this);
        initView();
        initData();
    }

    private void initData() {
        bitmapUtils.display(square_detail_headurl, squareEntity.getImageurl());
        bitmapUtils.display(square_detail_userimg, "http://imagecdn.xunjimap.com/image/" + squareEntity.getHeadurl());
        square_detail_username.setText(squareEntity.getUsername());
        square_detail_playcount.setText("播放 "+squareEntity.getArgs()+"");
        square_detail_description.setText(squareEntity.getDescription());
        square_detail_location.setText(squareEntity.getPlacename());
        square_detail_labels.setText(squareEntity.getLabels());

    }

    private void initView() {
        list_square_back = (ImageButton) findViewById(R.id.list_square_back);
        square_detail_headurl = (ImageView) findViewById(R.id.square_detail_headurl);
        square_detail_userimg = (CircleImageView) findViewById(R.id.square_detail_userimg);
        square_detail_username = (TextView) findViewById(R.id.square_detail_username);
        square_detail_playcount = (TextView) findViewById(R.id.square_detail_playcount);
        square_detail_description = (TextView) findViewById(R.id.square_detail_description);
        square_detail_location = (TextView) findViewById(R.id.square_detail_location);
        square_detail_labels = (TextView) findViewById(R.id.square_detail_labels);

        list_square_back.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.list_square_back:
                finish();
                break;
        }
    }
}
